//
//  XFRefreshHeaderView.m
//  WorkManager
//
//  Created by ukongm on 17/1/7.
//  Copyright © 2017年 ukongm. All rights reserved.
//

#import "XFRefreshHeaderView.h"
#import "XFRefreshConst.h"
#import "XFManager.h"

@implementation XFRefreshHeaderView

- (void)setStatus:(XFRefreshStatus)status{
    
    if (self.status == status) return;
    
    [super setStatus:status];
    
    switch (status) {
        case XFRefreshStatusNormal:
        {
            [UIView animateWithDuration:XFRefreshAnimationDuration animations:^{
                self.scrollView.contentInset = _scrollViewInitSet;
            }];
            break;
        }
        case XFRefreshStatusRefreshing:
        {
            [UIView animateWithDuration:XFRefreshAnimationDuration animations:^{
               
                UIEdgeInsets inset = self.scrollView.contentInset;
                inset.top = _scrollViewInitSet.top + self.height;
                self.scrollView.contentInset = inset;
                [self.scrollView setContentOffset: CGPointMake(0, -_scrollViewInitSet.top - self.height) animated:NO];
            }];
            break;
        }
        case XFRefreshStatusWillRefresh:
            
            break;
        case XFRefreshStatusPulling:
            break;
            
        default:
            break;
    }
}

- (NSInteger)viewStyle{
    return XFRefreshViewStyleHeader;
}

@end
